<?php
defined('BASE') or exit('Access Denied!'); 

/**
 * Obullo Framework (c) 2009.
 *
 * PHP5 MVC Minimalist Software for PHP 5.2.4 or newer
 * 
 *
 * @package         Obullo
 * @author          Obullo.com  
 * @subpackage      Base.database        
 * @copyright       Copyright (c) 2009 Ersin Güvenç.
 * @license         public
 * @since           Version 1.0
 * @filesource
 */ 

Class DBException extends CommonException {}  

/**
 * DBResults Class
 *
 * Fetch DB Results.
 *
 * @package         Obullo 
 * @subpackage      Base.database     
 * @category        Database
 * @version         0.1
 */ 

// predefined db constants
define('assoc','assoc'); 
define('obj','obj');
define('bound','bound');
define('col','col');
define('num','num');

// paramater types
define('p_int','int');
define('p_str','str');
define('p_bool','bool');
define('p_null','null');

// active record pdo secure like constant 
define('p_like','like');

Class DBResults
{
    // Factory fetch type
    public static function fetch($type='')
    {
        switch ($type)
        {                      
            case 'assoc':
            return PDO::FETCH_ASSOC;
            break;

            case 'obj':
            return PDO::FETCH_OBJ;
            break;
            
            //get column names and column nubers togetger
            case 'bound':
            return PDO::FETCH_BOUND;
            break;
            
            //get just column info
            case 'col':
            return PDO::FETCH_COLUMN;
            break;
            
            case 'num':
            return PDO::FETCH_NUM;
            break;

            default:
            return PDO::FETCH_ASSOC; 
        }   
    } //end fecth.
    
    
    public static function type($type='')
    {
        switch ($type)
        {                      
            // integer
            case 'int':
            return PDO::PARAM_INT;
            break;

            // string
            case 'str':
            return PDO::PARAM_STR;
            break;
            
            // boolean
            case 'bool':
            return PDO::PARAM_BOOL;
            break;
            
            default:
            return PDO::PARAM_STR; 
        }   
    }
    
    
}  //end class.

?>
